<template>
    <div>
        <el-table :data="list" style="width: 100%" max-height="500">
            <el-table-column fixed prop="landmarks.lmId" label="景区ID" width="150">
            </el-table-column>
            <el-table-column prop="landmarks.lmName" label="景区名" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.lmTelephone" label="联系电话" width="120" :formatter="formatRole">
            </el-table-column>
            <el-table-column prop="landmarks.lmPrice" label="门票价格" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.lmLabel" label="景区标签" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.lmDescription" label="景区描述" width="120" show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="landmarks.shopHours" label="营业时间" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.ticketsDescription" label="购票须知" width="120" show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="landmarks.otherInfo" label="其他信息" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.lmLng" label="经度" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.lmLat" label="纬度" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.lmAddr" label="结构化地址" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.province" label="省" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.city" label="市" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.area" label="区" width="120">
            </el-table-column>
            <el-table-column prop="landmarks.overallRating" label="总评分" width="120">
            </el-table-column>


            <el-table-column fixed="right" label="审核状态" width="120">
                <!-- <template slot-scope="scope">
                    <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                </template> -->

                <template slot-scope="scope" >
                    <!-- <el-button size="mini" type="info" v-if="scope.row.hotels.hotelId % 3  == 0">未审核</el-button>
                    <el-button size="mini" type="danger" v-else-if="scope.row.hotels.hotelId % 3  == 1">未通过</el-button> -->
                    <el-button size="mini" type="success">已通过</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="pageDto.page" :page-sizes="[5,10, 20, 30, 50]" :page-size="pageDto.size"
                layout="total, sizes, prev, pager, next, jumper" :total="100">
            </el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    name: "landmarktable",
    data() {
        return {
            pageDto: { page: 1, size: 10, landmarks: {} },
            list: [],
            displayList:[],
        }
    },
    methods: {
        // element ui
        // 分页
        handleSizeChange(val) {
            this.pageDto.size = val;
            this.queryByPage();
        },
        handleCurrentChange(val) {
            this.pageDto.page = val;
            this.queryByPage();
        },
        // 删除
        handleDelete(row) {
            this.$api.landmarksApi.deleteById({ lmId: row.landmarks.lmId }).then(res => {
                if (res.data.code == 1) {
                    this.$notify({
                        title: "成功",
                        message: "数据删除成功！",
                        type: "success",
                    });
                } else {
                    this.$notify.error({
                        title: "错误",
                        message: "数据删除失败！",
                    });
                }
            })
            this.queryByPage();
        },
        // 请求参数
        queryByPage(){
            this.$api.landmarksApi.queryByPage(this.pageDto).then(res=>{
                this.list = res.data.data;
                // this.displayList = this.list.map(item=>item.users)
                // console.log(this.displayList);
            })
        },
    },
    mounted() {
        this.queryByPage();
    },
}
</script>